/*
 * Copyright (c) 2013 XDream
 * Copyright (c) 2013 bruceshu <shuhuan.bruce@gmail.com>
 * 2024-8-7
 */

#ifndef AV_DEF_H
#define AV_DEF_H

#include <string>
#include <vector>

struct TrackInfo {
    int streamIndex;
    int streamType;
    int codecId;
    int codecProfile;
    int codecLevel;
    uint64_t bitRate;

    unsigned short width;
    unsigned short height;
    unsigned short sarNum;
    unsigned short sarDen;
    unsigned short fpsNum;
    unsigned short fpsDen;
    int rotation;
    int pixelFormat;

    int sampleRate;
    int sampleFmt;
    uint64_t channelLayout;
    int channels;

    uint8_t *extraData;
    int extraDataSize;

    TrackInfo() {
        streamIndex = -1;
        streamType = -1;
        codecId = 0;
        codecProfile = 0;
        codecLevel = 0;
        bitRate = 0;

        width = 0;
        height = 0;
        sarNum = 0;
        sarDen = 1;
        fpsNum = 0;
        fpsDen = 1;
        rotation = 0;
        pixelFormat = -1;

        sampleRate = 0;
        sampleFmt = 0;
        channelLayout = 0;
        channels = 0;

        extraData = nullptr;
        extraDataSize = 0;
    }
};

struct MetaData {
    std::string formatType;
    uint64_t duration;
    uint64_t startTime;
    uint64_t bitRate;
    int audioIndex;
    int videoIndex;
    int subIndex;
    std::vector<TrackInfo> trackInfo;

    MetaData() {
        formatType = "";
        duration = 0;
        startTime = 0;
        bitRate = 0;
        audioIndex = -1;
        videoIndex = -1;
        subIndex = -1;
    }

    ~MetaData() {
        for (auto iter = trackInfo.begin(); iter != trackInfo.end(); ++iter) {
            if (iter->extraData) {
                delete [] iter->extraData;
                iter->extraData = nullptr;
            }
        }
    }
};



#endif